package com.opticon.vaadinR.ui.demo;

import com.opticon.vaadinR.interfaces.VaadinRApplication;
import com.opticon.vaadinR.tools.density.DensityExecution;
import com.vaadin.ui.Button;
import com.vaadin.ui.TextField;

/**
 * This class is a
 */
public class DensityInputPanel extends AbstractInputPanel {

    private TextField txtField;

    public DensityInputPanel(VaadinRApplication aVaadinRApplication) {
        super(aVaadinRApplication);
    }

    @Override
    protected void addInputFields() {
        txtField = new TextField("mean");
        txtField = new TextField("mean");
        addComponent(txtField);
    }

    protected void initExecutionListener() {

        Button.ClickListener lExecutionListener = new Button.ClickListener() {
            public void buttonClick(Button.ClickEvent event) {
                DensityExecution worker = new DensityExecution(iVaadinRApplication.getRResultHandlerProvider().getDensityRResultHandler());

                worker.addObserver(DensityInputPanel.this);
                worker.setSessionID(iVaadinRApplication.getSessionID());
                worker.setMean(txtField.getValue().toString());

                worker.start();
                iExecutionProgress.setEnabled(true);
                iExecutionProgress.setVisible(true);
                iExecuteButton.setEnabled(false);
            }
        };

        iExecuteButton.addListener(lExecutionListener);
    }
}